package cn.lili.controller.payment;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.kit.RefundSupport;
import cn.lili.modules.payment.entity.enums.PaymentMethodEnum;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 买家端,退款回调
 *
 * @author Chopper
 * @since 2020-12-18 16:59
 */
@Api(tags = "买家端,退款回调")
@RestController
@RequestMapping("/payment/refund")
@RequiredArgsConstructor
public class CashierRefundController {

    private final RefundSupport refundSupport;

    @ApiOperation(value = "退款通知")
    @RequestMapping(value = "/notify/{paymentMethod}", method = {RequestMethod.GET, RequestMethod.POST})
    public String notify(@PathVariable String paymentMethod) {
        PaymentMethodEnum paymentMethodEnum = PaymentMethodEnum.paymentNameOf(paymentMethod);
        refundSupport.notify(paymentMethodEnum);

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("SUCCESS",200);
        return jsonObject.toJSONString();
    }
}
